ci:
  autofix_commit_msg: |
    [pre-commit.ci] auto fixes from pre-commit.ci hooks

    for more information, see https://pre-commit.ci
  autofix_prs: true
  autoupdate_commit_msg: "chore: pre-commit autoupdate"
  autoupdate_schedule: weekly

repos:
  - repo: local
    hooks:
      - id: check-poetry-lock
        # `pre-commit autoupdate` will update to older Poetry versions, so we
        # use a local hook to avoid that bug:
        # https://github.com/meltano/meltano/pull/7238#issuecomment-1409434351
        name: check that `poetry.lock` conforms to `pyproject.toml`
        entry: sh -c 'find . -type f -name poetry.lock -print0 | xargs -0 -n 1 -P 0 sh -c 'cd "$(dirname "$1")" && echo "$(pwd)/poetry.lock" && poetry lock --check' _ {} \;'
        language: python
        pass_filenames: false
        additional_dependencies:
          - "poetry==1.6.1"

  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: trailing-whitespace
        exclude: ^src/meltano/core/cli_messages\.py$
      - id: end-of-file-fixer
        exclude: ^.*/plugins/.*/.*\.lock$
      - id: check-yaml
      - id: check-json
      - id: pretty-format-json
        args: ["--autofix", "--indent=2", "--no-sort-keys"]
      - id: check-added-large-files
      - id: check-merge-conflict
      - id: check-toml
      - id: debug-statements

  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.28.2
    hooks:
      - id: check-metaschema
        name: validate JSON schemas against meta schemas
        files: ^schemas?/.*\.json$
      - id: check-jsonschema
        name: validate 'meltano.yml' with jsonschema
        files: .*/meltano.yml$
        args: ["--schemafile", "src/meltano/schemas/meltano.schema.json"]
      - id: check-jsonschema
        name: validate 'discovery.yml' with jsonschema
        files: ^src/meltano/core/bundle/discovery.yml$
        args: ["--schemafile", "src/meltano/schemas/discovery.schema.json"]

  - repo: https://github.com/shellcheck-py/shellcheck-py
    rev: v0.10.0.1
    hooks:
      - id: shellcheck
        name: shellcheck
        exclude: ^integration/mdsh$

  - repo: https://github.com/pre-commit/mirrors-eslint
    rev: v8.55.0 # Keep this in sync with the eslint "additional_dependency" below!
    hooks:
      - id: eslint
        files: \.[jt]sx?$
        args: ['--fix', '--config=docs/.eslintrc.json']
        additional_dependencies:
          - "eslint@8.55.0" # Keep this in sync with the rev above!
          - "eslint-config-prettier@8.8.0"
          - "eslint-plugin-prettier@5.0.0"
          - "eslint-plugin-react@7.33.0"
          - "eslint-plugin-vue@9.15.1"
          - "prettier@3.0.0"

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.4.3
    hooks:
    - id: ruff
      args: [--fix, --exit-non-zero-on-fix, --show-fixes]
    - id: ruff-format
      exclude: ^(src/meltano/migrations/)

  - repo: https://github.com/flakeheaven/flakeheaven
    rev: 3.3.0
    hooks:
      - id: flakeheaven
        exclude: ^(src/meltano/migrations/)
        args:
          - "--max-local-variables=8"
        language_version: python3.11
        additional_dependencies:
          - flake8==4.0.1
          - flake8-bandit==3.0.0
          - flake8-broken-line==0.4.0
          - flake8-bugbear==22.12.6
          - flake8-commas==2.1.0
          - flake8-comprehensions==3.10.1
          - flake8-docstrings==1.6.0
          - flake8-eradicate==1.4.0
          - flake8-polyfill==1.0.2
          - flake8-rst-docstrings==0.2.7
          - flake8-string-format==0.3.0
          - flake8-typing-as-t==0.0.3
          - wemake-python-styleguide==0.16.1
